package DAO;

import Models.PriceList;
import Interfaces.IPriceList_Dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class PriceList_Dao implements IPriceList_Dao {

    @Override
    public PriceList insertPricelist(String fmpoukali, String fpoto, String fmpyra, String fsfinaki, String fmiso, String kmpoukali, String kpoto, String kmpyra, String ksfinaki, String kmiso) throws IllegalArgumentException {
        Connection conn = null;
        PreparedStatement pst = null;
        try {
            conn = javaconnect.connectDB();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(PriceList_Dao.class.getName()).log(Level.SEVERE, null, ex);
        }

        try {
            String query = "INSERT INTO pricelist (fmpoukali , fpoto , fmpyra , fsfinaki , fmiso , kmpoukali , kpoto, kmpyra, ksfinaki , kmiso ) value (?,?,?,?,?,?,?,?,?,?)";
            pst = conn.prepareStatement(query);
            pst.setString(1, fmpoukali);
            pst.setString(2, fpoto);
            pst.setString(3, fmpyra);
            pst.setString(4, fsfinaki);
            pst.setString(5, fmiso);
            pst.setString(6, kmpoukali);
            pst.setString(7, kpoto);
            pst.setString(8, kmpyra);
            pst.setString(9, ksfinaki);
            pst.setString(10, kmiso);

            pst.execute();
            pst.close();
            conn.close();
        } catch (SQLException e) {
            throw new IllegalArgumentException("Error in PriceList_Dao");
        }
        return null;

    }
}
